package com.demo.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/")
public class RedisController {
    @Autowired
    private RedisTemplate redisTemplate;


    @RequestMapping("redis")
    @ResponseBody
    public String  redistest(){
        System.out.println("--------redistest method test-------");
        String key = "tk";

        BoundValueOperations<String,String> bops = redisTemplate.boundValueOps(key);
        bops.set("v111111111111");
        redisTemplate.opsForValue().set(key,"v222222222222222222");
        String str = redisTemplate.opsForValue().get(key).toString();
        System.out.println(str);
        return str;
    }
}
